package com.own.business.resource.entity.dto;

import com.own.business.resource.entity.bo.FileRecordBo;
import com.own.component.common.base.entity.BaseDto;
import com.own.constant.ConstantBeanSuffix;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.io.Serializable;

/**
 * FileRecordDto
 *
 * @author chenxueli
 * @date 2023-07-07 14:06:30
 */
@Schema(title = "文件记录表" + ConstantBeanSuffix.DTO)
@Getter
@Setter
@ToString
@Accessors(chain = true)
@AllArgsConstructor
@NoArgsConstructor
public class FileRecordDto extends BaseDto<FileRecordBo> implements Serializable {

    @Schema(title = "文件名称")
    private String name;

    @Schema(title = "文件原名称")
    private String oldName;

    @Schema(title = "文件地址（相对路径）")
    private String path;

    @Schema(title = "文件位置")
    private String position;

    @Schema(title = "文件类型")
    private String type;

    @Schema(title = "文件大小（字节）")
    private Long size;

    @Schema(title = "文件的md5值")
    private String md5;

    /**
     * 转业务层对象
     *
     * @param entity 原业务层对象
     * @return 业务层对象
     */
    @Override
    public FileRecordBo toBo(FileRecordBo entity) {
        if (entity == null) {
            entity = new FileRecordBo();
        }
        entity.setName(name);
        entity.setOldName(oldName);
        entity.setPath(path);
        entity.setPosition(position);
        entity.setType(type);
        entity.setSize(size);
        entity.setMd5(md5);
        return super.toBo(entity);
    }

}
